<%
var headContent = {
include("/pages/template/head.html"){}
%>
<script type="text/javascript">
jQuery(function () {
 // 时间设置
   $('#timepicker1').datetimepicker({
        showSecond : true,
		timeFormat : 'HH:mm:ss',
		stepHour : 1,
		stepMinute : 1,
		stepSecond : 1
            });
	$("#timepicker2").datetimepicker({
		showSecond : true,
		timeFormat : 'HH:mm:ss',
		stepHour : 1,
		stepMinute : 1,
		stepSecond : 1
	});
});

    var oper;
    jQuery(function($) {
        // 页面方法
        oper = {
            width : 450,
            height : 500,
            form : document.form1,
            list : function() {
                var url = 'system/orderinfo/queryListForErr';
                this.form.action = url;
                this.form.submit();
            },
            view : function(id) {
                var url = 'system/orderinfo/getErrView/'+id;
                var title = '查看订单信息';
                Iframe(url, this.width, this.height, title, false, false, false, EmptyFunc);
            },
           doQuery:function(id){
	            var url = 'system/orderinfo/doQuery/'+id;
	          var title = '确认要？';
                Confirm(title, function() {
                    form1.action = url;
                    form1.submit();
                });
            },
              
           doOrder:function(id){
	            var url = 'system/orderinfo/doOrder/'+id;
	            form1.action = url;
	            form1.submit();
	            return true;
       		},
           setFail:function(id){
	            var url = 'system/orderinfo/setFail/'+id;
	            form1.action = url;
	            form1.submit();
	            return true;
       		}
        };
        //显示Menu索引
        showMenu('page_system');
        showMenu('page_customerinfo');
    });

    //分页
    var paginator = function(page) {
        oper.list();
    };

</script>

<%
};

var bodyContent = {
%>
<form name="form1" action="" method="post"  class="form-inline" role="form">
	<!-- 菜单 -->
	<% include("/pages/template/menu.html"){} %>

	<div class="tableSearch">
		<%  //查询列表 %>
		<div class="form-group">
			<input class="form-control" type="text" name="attr.ids" value="${attr.ids!''}"
				   placeholder="请输入订单ID" required='required' />
		</div>
		<div class="form-group">
			<input class="form-control" type="text" name="attr.phoneNo" value="${attr.phoneNo!''}"
				   placeholder="请输入手机号"  />
		</div>
		<div class="form-group">
				<select name="attr.customerId" class="form-control"  style = "width:196px;">
				<option value="">请选择客户</option>
				${selectCustomer }
				</select>
		</div>
		<div class="form-group">
		 	<select name="attr.operator" class="form-control" style = "width:196px;">
				<option value="">请选择运营商</option>
				<option value="1" ${attr.operator=="1"?"selected":"" }>中国电信</option>
				<option value="2" ${attr.operator=="2"?"selected":"" }>中国移动</option>
				<option value="3" ${attr.operator=="3"?"selected":"" }>中国联通</option>
			</select>
		</div>
		<div class="form-group">
		 	<select name="attr.status" class="form-control"  style = "width:196px;" >
				<option value="">请选择订单状态</option>
				<option value="0" ${attr.status=="0"?"selected":"" }>受理中</option>
				<option value="1" ${attr.status=="1"?"selected":"" }>订购中</option>
			</select>
		</div>
		
		
		<div class="form-group">
			<input id = "timepicker1" class="form-control" type="text" name="startTime" value="${startTime!""}"
				   placeholder="请输入开始时间" required='required' />
		</div>
		
		<div class="form-group">
			<input id = "timepicker2" class="form-control" type="text" name="endTime" value="${endTime!""}"
				   placeholder="请输入结束时间" required='required' />
		</div>
		
		
		<button type="button" class="btn btn-default" onclick="resetForm();">
			<span class="glyphicon glyphicon-refresh"></span> 重 置
		</button>
		<button type="button" class="btn btn-default" onclick="oper.list();" name="search">
			<span class="glyphicon glyphicon-search"></span> 查 询
		</button>
	</div>

	<!-- 数据列表 -->
	<table class="table table-striped table-bordered table-hover">
		<thead>
		<tr>
			<th>序号</th>
			<%  // 列表头部 %>
			<th style="display:none" name="customerId" class="sorting">customerId</th>
			<th name="o.ids" class="sorting">订单号</th>
			<th name="o.cstmOrderNo" class="sorting">客户流水号</th>
			<th name="c.customerName" class="sorting">客户名称</th>
			<th name="o.channel" class="sorting">供应商</th>
			<th name="o.sellPrice" class="sorting">订单金额(元)</th>
			<th name="o.productName" class="sorting">商品名称</th>
			<th name="o.phoneNo" class="sorting">手机号</th>
			<th name="o.status" class="sorting">订单状态</th>
			<th name="o.isPay" class="sorting">计费状态</th>
			<th name="o.orderTime" class="sorting">订购时间</th>
			<th name="o.openTime" class="sorting">开通时间</th>
			<th>操作</th>
		</tr>
		</thead>
		<tbody>
		<% for(item in page.list){ %>
		<tr>
			<td>${itemLP.index }</td>
			<%  // 列表内容 %>
			<td>${item.ids}</td>
			<td>${item.cstmOrderNo}</td>
			<td>${item.customerName}</td>
			<td>${item.channel}</td>
			<td>${item.sellPrice}</td>
			<td>${item.productName}</td>
			<td>${item.phoneNo}</td>
			<td>
				<% if(item.status=="1") { %>
				<span class ="font-success">订购中</span>
				<%	} %>
				<% if(item.status=="0") { %>
				<span class ="font-success">受理中</span>
				<%	} %>
				<% if(item.status=="7") { %>
				<span class ="font-success">订购成功</span>
				<%	} %>
				<% if(item.status=="8") { %>
				<span class ="font-danger">订购失败</span>
				<%	} %>
			</td>
			<td>
				<% if(item.isPay=="1") { %>
				<span class ="font-danger">系统退费</span>
				<%	} %>
				<% if(item.isPay=="0") { %>
				<span class ="font-success">系统扣费</span>
				<%	} %>
				<% if(item.isPay=="2") { %>
				<span class ="font-success">退款成功</span>
				<%	} %>
				<% if(item.isPay=="3") { %>
				<span class ="font-danger">退款失败</span>
				<%	} %>
			</td>
			<td>${item.orderTime}</td>
			<td>${item.openTime}</td>
			<td width="10%" class="center" >
					<!--	<a href="javascript:void(0);" class="btn btn-sm btn-success" onclick="oper.view('${item.ids}');">查看</a>-->
				<% if(item.status == '0' && order.message == '无订单'){ %> 
						<a href="javascript:void(0);" class="btn btn-sm btn-success" onclick="oper.doOrder('${item.ids}');">订购</a>
				<%}%> 
				
				<% if(item.message == '无订单' ){ %> 
						<a href="javascript:void(0);" class="btn btn-sm btn-danger" onclick="oper.setFail('${item.ids}');">失败</a>
				<% } %>
				
				<% if( item.message != '无订单' ){ %> 
						<a href="javascript:void(0);" class="btn btn-sm btn-primary" onclick="oper.doQuery('${item.ids}');">同步</a>
				<% } %>
				</td>
		</tr>
		<% } %>
		</tbody>
	</table>
	<%include("/pages/includes/paginator.html"){} %>
</form>
<%}; %>


<% layout("/pages/template/_layout.html",{head:headContent,body:bodyContent}){ %>
<%} %>